//
//  BCBaseTabBarController.m
//  BananaChat
//
//  Created by 于洪东 on 2019/11/1.
//  Copyright © 2019 香蕉. All rights reserved.
//

#import "BCBaseTabBarController.h"
#import "BCBaseNavigationController.h"

@interface BCBaseTabBarController ()<UITabBarDelegate,UITabBarControllerDelegate>

@end

@implementation BCBaseTabBarController


- (void)viewDidLoad {
    [super viewDidLoad];
    [self addChildViewControllers];
}

- (void)addChildViewControllers {
    [self setupChildViewControllerWithVcString:@"BCTrendsVC" imageName:@"wode_icon" selectedImage:@"wode_select_icon" title:@"动态" tag:1000];
    [self setupChildViewControllerWithVcString:@"BCVideoChatVC" imageName:@"wode_icon" selectedImage:@"wode_select_icon" title:@"视频聊" tag:1001];
    [self setupChildViewControllerWithVcString:@"BCMessageVC" imageName:@"wode_icon" selectedImage:@"wode_select_icon" title:@"消息" tag:1002];
    [self setupChildViewControllerWithVcString:@"BCUserMeVC" imageName:@"wode_icon" selectedImage:@"wode_select_icon" title:@"我" tag:1003];
}

- (void)setupChildViewControllerWithVcString:(NSString *)vcString imageName:(NSString *)imageName selectedImage:(NSString *)selectedImage title:(NSString *)title  tag:(NSInteger)tag{
    Class cls = NSClassFromString(vcString);
    UIViewController *vc = [[cls alloc] init];
    vc.title = title;
    vc.tabBarItem.image = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    vc.tabBarItem.tag = tag;
    
    vc.tabBarItem.selectedImage = [[UIImage imageNamed:selectedImage] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:NTMainColor} forState:UIControlStateSelected];
    [vc.tabBarItem setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor colorWithHexString:@"#878787"]} forState:UIControlStateNormal];
    self.delegate = self;
    BCBaseNavigationController *nav = [[BCBaseNavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
    
}


#pragma mark -
-(void)tabBar:(UITabBar *)tabBar didSelectItem:(UITabBarItem *)item{

}

-(BOOL)tabBarController:(UITabBarController *)tabBarController shouldSelectViewController:(UIViewController *)viewController{
    return YES;
}

@end
